<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:s="http://jboss.com/products/seam/taglib"
     >
      <body style="overflow: hidden">
       
       <h:form>
       
       <a4j:include viewId="toolBar.xhtml"/>
      
       
      
             
        <rich:datascroller for="fiListTable" id="fi_sc" />
        <div style="overflow-y:auto;width:100%;height:85%">
           
            <rich:dataTable id="fiListTable" width="100%" rows="50" value="#{fiListSession.banks}" var="b" reRender="fi_sc">
                <rich:column style="text-align:center"  filterBy="#{b.code}"  filterEvent="onkeyup" sortBy="#{b.code}">
                    <f:facet name="header">
                        #{messages['fina2.code']}
                    </f:facet>
                    #{b.code}
                </rich:column>
                <rich:column style="text-align:center" filterBy="#{b.name}" filterEvent="onkeyup" sortBy="#{b.name}">
                    <f:facet name="header">
                        #{messages['fina2.bank.name']}
                    </f:facet>
                    #{b.name}
                </rich:column>
                <rich:column style="text-align:center" filterBy="#{b.bankType.code}" filterEvent="onkeyup" sortBy="#{b.bankType.code}">
                    <f:facet name="header">
                       FI Code
                    </f:facet>
                    #{b.bankType.code}
                </rich:column>
                
                <rich:column style="text-align:center" sortIcon="/images/edit.gif">
                    <f:facet name="header">
                       #{messages['fina2.amend']}
                    </f:facet>
                    <a4j:commandLink disabled="#{(!userSession.hasPermission('fina2.bank.amend'))&amp;&amp;(!roleSession.hasPermission(userSession.currentUser.id,'fina2.bank.amend'))}" action="#{fiListSession.setSelectedBank(b)}" onclick="Richfaces.showModalPanel('loading')" oncomplete="Richfaces.hideModalPanel('loading');Richfaces.showModalPanel('bank_amend_panel')" reRender="bank_amend_table">
                        <h:graphicImage value="/images/edit.gif" style="border:0" />
                    </a4j:commandLink>
                </rich:column>
                <rich:column style="text-align:center" sortIcon="/images/remove.gif">
                    <f:facet name="header">
                       #{messages['fina2.delete']}
                    </f:facet>
                    <a4j:commandLink action="#{fiListSession.setBankToRemove(b)}" oncomplete="Richfaces.showModalPanel('confirmation')" disabled="#{(!userSession.hasPermission('fina2.bank.delete'))&amp;&amp;(!roleSession.hasPermission(userSession.currentUser.id,'fina2.bank.delete'))}">
                        <h:graphicImage value="/images/remove.gif" style="border:0" />
                    </a4j:commandLink>
                </rich:column>
            </rich:dataTable>
        </div>
       </h:form>
       
       <rich:modalPanel id="confirmation" autosized="true" resizeable="false" width="300" >
           <f:facet name="header">
               #{messages['fina2.web.confirm']}
           </f:facet>
           <f:facet name="controls">
               <h:graphicImage value="../images/close.gif"  onclick="Richfaces.hideModalPanel('confirmation')"/>
           </f:facet>
           <h:form>
               <s:div id="removeBank">
                   <table align="center" width="100%" style="font-size:12px">
                       <tr>
                          <td style="font-size:12px">#{messages['fina2.bank.bankDeleteQuestion']}</td>
                       </tr>
                   </table>
              </s:div>
              <rich:spacer height="5px"/>
              <table align="center">
                  <tr>
                      <td>
                          <a4j:commandButton action="#{fiListSession.removeFi()}" reRender="fiListTable,fi_sc" value="#{messages['fina2.web.ok']}" style="width:80px" oncomplete="Richfaces.hideModalPanel('confirmation')"/>
                      </td>
                      <td><rich:spacer width="3px"/></td>
                      <td><a4j:commandButton onclick="Richfaces.hideModalPanel('confirmation')" value="#{messages['fina2.web.cancel']}" style="width:80px"/></td>
                  </tr>
             </table>
        </h:form>
       </rich:modalPanel>
       
       <rich:modalPanel id="bank_amend_panel"  resizeable="false" width="500" height="370">
           <f:facet name="header">
             Bank Amend
           </f:facet>
           <f:facet name="controls">
               <h:graphicImage value="/images/close.gif" onclick="Richfaces.hideModalPanel('bank_amend_panel')" />
           </f:facet>
           <h:form>
           <s:div id="bank_amend_table">
               <rich:tabPanel height="250px" switchType="client">
               <rich:tab label="Main">
               <f:facet name="beforeInvalidField">
                   <s:message style="font-size:12px;color:red"/>
               </f:facet>
               <f:facet name="aroundInvalidField">
               
               </f:facet>
               <f:facet name="afterInvalidField">
                   <s:div style="display:block;padding-bottom:1px"/>
               </f:facet>
               <s:div id="amend_bank_panel_table">
               <table align="center" width="100%" style="font-size:12px" >
                <tr>
                    <td width="50%">#{messages['fina2.bank.bankGroupDefault']}</td>
                    <td style="color:red" >*</td>
                    <td>
                        <rich:spacer width="2px"/>
                        <h:selectOneMenu value="#{fiBankAddData.selectedGroup}" style="width:307px">
                            <f:selectItems value="#{fiBankAddData.bankGroups}"/>
                        </h:selectOneMenu>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.code']}</td>
                    <td style="color:red">*</td>
                    <td>
                        <rich:spacer width="2px"/>
                        <s:decorate>
                            <h:inputText required="true"  requiredMessage="Code is required" validator="#{fiAddBankValidator.validateCode}" value="#{fiListSession.selectedBank.code}" style="width:307px">
                               <s:validate />
                            </h:inputText>
                        </s:decorate>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.bank.branchShortName']}</td>
                    <td style="color:red">*</td>
                    <td>
                        <table  style="font-size:12px" width="100%">
                            <tr>
                                <td>
                                    <s:decorate>
                                        <h:inputText required="true" requiredMessage="Short Name is required" validator="#{fiAddBankValidator.validateName}" value="#{fiListSession.selectedBank.shortName}" style="width:120px">
                                            <s:validate/>
                                        </h:inputText>
                                    </s:decorate>
                                </td>
                                <td>
                                    #{messages['fina2.bank.swiftCode']}
                                    <rich:spacer width="5px"/>
                                </td>
                                <td><h:inputText value="#{fiListSession.selectedBank.swiftCode}" style="width:120px"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.bank.name']}</td>
                    <td style="color:red">*</td>
                    <td>
                        <rich:spacer width="2px"/>
                        <s:decorate>
                            <h:inputText required="true" requiredMessage="Name is required" validator="#{fiAddBankValidator.validateName}" value="#{fiListSession.selectedBank.name}" style="width:307px" >
                                <s:validate/>
                            </h:inputText>
                        </s:decorate>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.bank.address']}</td>
                    <td style="color:red"> </td>
                    <td>
                        <rich:spacer width="2px"/>
                        <h:inputText value="#{fiListSession.selectedBank.address}" style="width:307px" />
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.security.phone']}</td>
                    <td style="color:red"></td>
                    <td>
                        <table align="center" style="font-size:12px" width="100%">
                            <tr>
                                <td>
                                    <h:inputText value="#{fiListSession.selectedBank.phone}" style="width:120px"/>
                                </td>
                                <td>
                                    <rich:spacer width="12px"/>
                                    #{messages['fina2.bank.fax']}
                                    <rich:spacer width="27px"/>
                                </td>
                                <td><h:inputText value="#{fiListSession.selectedBank.fax}" style="width:120px"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.security.email']}</td>
                    <td style="color:red"></td>
                    <td><h:inputText value="#{fiListSession.selectedBank.email}" style="width:307px"/></td>
                </tr>
                <tr>
                    <td>#{messages['fina2.bank.bankType']}</td>
                    <td style="color:red">*</td>
                    <td>
                        <rich:spacer  width="2px"/> 
                        <h:selectOneMenu value="#{fiBankAddData.selectedFiType}" style="width:307px">
                          <f:selectItems value="#{fiBankAddData.fiTypes}"/>
                        </h:selectOneMenu>
                    </td>
                </tr>
            </table>
            </s:div>
           
            <table align="center" style="font-size:12px">
                <tr>
                    <td>
                        <a4j:commandButton  value="Submit Changes" style="width:100px" />
                    </td>
                    <td><rich:spacer width="3px"/></td>
                    <td>
                        <a4j:commandButton value="#{messages['fina2.cancel']}" style="width:100px" onclick="Richfaces.hideModalPanel('bank_amend_panel')"/>
                    </td>
                </tr>
            </table>
           
      
                  </rich:tab>
                  <rich:tab label="Bank Groups"  >
                              <div  style="overflow-y:auto;height:250px">
                              <rich:tree  switchType="client" iconLeaf="/images/node.gif">
                                <rich:treeNodesAdaptor  nodes="#{critSession.allCriterions}" var="crit">
                                 <rich:treeNode>
                                  #{crit.code}/#{crit.description}
                                 </rich:treeNode>
                                 <rich:treeNodesAdaptor  nodes="#{crit.bankGroups}" var="gr">
                                 <rich:treeNode>
                                  <h:selectBooleanCheckbox value="false" />
                                  #{gr.code}/#{gr.description}
                                 </rich:treeNode>
                                 </rich:treeNodesAdaptor>
                               </rich:treeNodesAdaptor>
                              </rich:tree>
                              </div>
                              <table align="center" >
                                  <tr>
                                      <td>
                                          <a4j:commandButton  value="Submit Changes" style="width:100px" />
                                      </td>
                                      <td>
                                          <rich:spacer width="3"/>
                                      </td>
                                      <td>
                                          <a4j:commandButton value="#{messages['fina2.cancel']}" onclick="Richfaces.hideModalPanel('bank_amend_panel')" ajaxSingle="true" style="width:100px"/>
                                      </td>
                                  </tr>
                              </table>
                          </rich:tab>
                          <rich:tab label=" Licences"> 
                              <!-- Licences -->
                            
                              <rich:datascroller for="b_lics"/>
                              <div style="overflow-y:auto;width:100%;height:100%">
                              <rich:dataTable width="100%" align="center" rows="15" id="b_lics" value="#{fiListSession.selectedBank.licenceTypes}" var="lic" >
                                  <rich:column sortBy="#{lic.description}" style="text-align:center">
                                      <f:facet name="header">
                                        Name
                                      </f:facet>
                                      #{lic.description}
                                  </rich:column>
                                 
                                  <rich:column sortIcon="/images/edit.gif" style="text-align:center">
                                      <f:facet name="header">
                                        #{messages['fina2.amend']}
                                      </f:facet>
                                      <a4j:commandButton disabled="#{!userSession.hasPermission('fina2.bank.amend')}" image="/images/edit.gif" style="border:0" />
                                      
                                  </rich:column>
                                  <rich:column sortIcon="/images/remove.gif" style="text-align:center">
                                      <f:facet name="header">
                                        #{messages['fina2.delete']}
                                      </f:facet>
                                      <a4j:commandButton disabled="#{!userSession.hasPermission('fina2.bank.delete')}" image="/images/remove.gif" style="border:0" />
                                  </rich:column>
                              </rich:dataTable>
                              </div>
                             
                         </rich:tab>
                         <rich:tab label="Branches">
                              <!-- Branch -->
                              
                              <rich:datascroller for="b_br"/>
                              <div style="overflow-y:auto;width:100%;height:100%">
                                  <rich:dataTable align="center" id="b_br" value="#{fiListSession.selectedBank.bankBranches}" var="bb" rows="15" width="100%">
                                      <rich:column sortBy="#{bb.region.cityName}" style="text-align:center">
                                          <f:facet name="header">
                                          City
                                          </f:facet>
                                          #{bb.region.cityName}
                                      </rich:column>
                                      <rich:column sortBy="#{bb.region.regionName}" style="text-align:center">
                                          <f:facet name="header">
                                          Region
                                          </f:facet>
                                          #{bb.region.regionName}
                                      </rich:column>
                                      <rich:column sortBy="#{bb.shortName}" style="text-align:center">
                                          <f:facet name="header">
                                           Short Name
                                          </f:facet>
                                          #{bb.shortName}
                                      </rich:column>
                                      <rich:column sortIcon="/images/edit.gif" style="text-align:center">
                                          <f:facet name="header">
                                           #{messages['fina2.amend']}
                                          </f:facet>
                                          <a4j:commandButton disabled="#{!userSession.hasPermission('fina2.bank.amend')}" image="/images/edit.gif" style="border:0" />
                                      </rich:column>
                                      <rich:column sortIcon="/images/remove.gif" style="text-align:center">
                                          <f:facet name="header">
                                           #{messages['fina2.delete']}
                                          </f:facet>
                                          <a4j:commandButton disabled="#{!userSession.hasPermission('fina2.bank.delete')}" image="/images/remove.gif" style="border:0" />
                                      </rich:column>
                                  </rich:dataTable>
                              </div>
                         </rich:tab>
                         <rich:tab label="Management">
                             <!-- Management -->
                            
                              
                             
                             <rich:datascroller for="b_mng"/>
                             <div style="overflow-y:auto;width:100%;height:100%">
                                 <rich:dataTable id="b_mng" width="100%" value="#{fiListSession.selectedBank.bankMan}" var="bm" align="center" rows="15">
                                     <rich:column sortBy="#{bm.post}" style="text-align:center">
                                         <f:facet name="header">
                                           Post
                                         </f:facet>
                                         #{bm.post}
                                     </rich:column>
                                     <rich:column sortBy="#{bm.name}" style="text-align:center">
                                         <f:facet name="header">
                                           FirstName
                                         </f:facet>
                                         #{bm.name}
                                     </rich:column>
                                     <rich:column sortBy="#{bm.lastName}" style="text-align:center">
                                         <f:facet name="header">
                                           LastName
                                         </f:facet>
                                         #{bm.lastName}
                                     </rich:column>
                                     <rich:column sortIcon="/images/edit.gif" style="text-align:center">
                                         <f:facet name="header">
                                          #{messages['fina2.amend']}
                                         </f:facet>
                                         <a4j:commandButton disabled="#{!userSession.hasPermission('fina2.bank.amend')}" image="/images/edit.gif" style="border:0"/>
                                     </rich:column>
                                     <rich:column sortIcon="/images/remove.gif" style="text-align:center">
                                         <f:facet name="header">
                                          #{messages['fina2.delete']}
                                         </f:facet>
                                         <a4j:commandButton disabled="#{!userSession.hasPermission('fina2.bank.delete')}" image="/images/remove.gif" style="border:0"/>
                                     </rich:column>
                                 </rich:dataTable>
                                 
                             </div>
                             
                             </rich:tab>
                         
                
                             <!-- History -->
                             <rich:tab label="History">
                                <rich:spacer height="20px"/>
                                <h:inputTextarea value="Add History" style="width:400px;height:220px"/>
                                <table align="center">
                                    <tr>
                                        <td><a4j:commandButton value="Add History" style="width:100px" /></td>
                                        <td><rich:spacer width="3"/></td>
                                        <td><a4j:commandButton value="#{messages['fina2.cancel']}" onclick="Richfaces.hideModalPanel('bank_amend_panel')" style="width:100px"/></td>
                                    </tr>
                                    
                                </table>
                             </rich:tab>
                            
                  </rich:tabPanel>
               </s:div>
               
           </h:form>
           
       </rich:modalPanel>
       
       <rich:modalPanel id="bank_add_panel"  resizeable="false" width="500" height="370">
           <f:facet name="header">
             Bank Amend
           </f:facet>
           <f:facet name="controls">
               <h:graphicImage value="/images/close.gif" onclick="Richfaces.hideModalPanel('bank_add_panel')" />
           </f:facet>
           <h:form>
           <s:div id="bank_add_table">
               
               <f:facet name="beforeInvalidField">
                   <s:message style="font-size:12px;color:red"/>
               </f:facet>
               <f:facet name="aroundInvalidField">
               
               </f:facet>
               <f:facet name="afterInvalidField">
                   <s:div style="display:block;padding-bottom:1px"/>
               </f:facet>
             
               <table align="center" width="100%" style="font-size:12px" >
                <tr>
                    <td width="50%">#{messages['fina2.bank.bankGroupDefault']}</td>
                    <td style="color:red" >*</td>
                    <td>
                        <rich:spacer width="2px"/>
                        <h:selectOneMenu value="#{fiBankAddData.selectedGroup}" style="width:307px">
                            <f:selectItems value="#{fiBankAddData.bankGroups}"/>
                        </h:selectOneMenu>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.code']}</td>
                    <td style="color:red">*</td>
                    <td>
                        <rich:spacer width="2px"/>
                        <s:decorate>
                            <h:inputText required="true"  requiredMessage="Code is required" validator="#{fiAddBankValidator.validateCode}" value="#{fiBankAddData.code}" style="width:307px">
                               <s:validate />
                            </h:inputText>
                        </s:decorate>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.bank.branchShortName']}</td>
                    <td style="color:red">*</td>
                    <td>
                        <table  style="font-size:12px" width="100%">
                            <tr>
                                <td>
                                    <s:decorate>
                                        <h:inputText required="true" requiredMessage="Short Name is required" validator="#{fiAddBankValidator.validateName}" value="#{fiBankAddData.shortName}" style="width:120px">
                                            <s:validate/>
                                        </h:inputText>
                                    </s:decorate>
                                </td>
                                <td>
                                    #{messages['fina2.bank.swiftCode']}
                                    <rich:spacer width="5px"/>
                                </td>
                                <td><h:inputText value="#{fiBankAddData.swiftCode}" style="width:120px"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.bank.name']}</td>
                    <td style="color:red">*</td>
                    <td>
                        <rich:spacer width="2px"/>
                        <s:decorate>
                            <h:inputText required="true" requiredMessage="Name is required" validator="#{fiAddBankValidator.validateName}" value="#{fiBankAddData.name}" style="width:307px" >
                                <s:validate/>
                            </h:inputText>
                        </s:decorate>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.bank.address']}</td>
                    <td style="color:red"> </td>
                    <td>
                        <rich:spacer width="2px"/>
                        <h:inputText value="#{fiBankAddData.address}" style="width:307px" />
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.security.phone']}</td>
                    <td style="color:red"></td>
                    <td>
                        <table align="center" style="font-size:12px" width="100%">
                            <tr>
                                <td>
                                    <h:inputText value="#{fiBankAddData.phone}" style="width:120px"/>
                                </td>
                                <td>
                                    <rich:spacer width="12px"/>
                                    #{messages['fina2.bank.fax']}
                                    <rich:spacer width="27px"/>
                                </td>
                                <td><h:inputText value="#{fiBankAddData.fax}" style="width:120px"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>#{messages['fina2.security.email']}</td>
                    <td style="color:red"></td>
                    <td><h:inputText value="#{fiBankAddData.email}" style="width:307px"/></td>
                </tr>
                <tr>
                    <td>#{messages['fina2.bank.bankType']}</td>
                    <td style="color:red">*</td>
                    <td>
                        <rich:spacer  width="2px"/> 
                        <h:selectOneMenu value="#{fiBankAddData.selectedFiType}" style="width:307px">
                          <f:selectItems value="#{fiBankAddData.fiTypes}"/>
                        </h:selectOneMenu>
                    </td>
                </tr>
            </table>
            </s:div>
           
            <table align="center" style="font-size:12px">
                <tr>
                    <td>
                        <a4j:commandButton data="#{fiListSession.bankAdded}"  action="#{fiListSession.addBank(fiBankAddData.selectedGroup,fiBankAddData.code,fiBankAddData.shortName,fiBankAddData.swiftCode,fiBankAddData.name,fiBankAddData.address,fiBankAddData.phone,fiBankAddData.fax,fiBankAddData.email,fiBankAddData.selectedFiType)}" ajaxSingle="true" reRender="fiListTable,fi_sc,bank_add_table" oncomplete="if(data)Richfaces.hideModalPanel('bank_add_panel')" value="Submit Changes" style="width:100px" />
                    </td>
                    <td><rich:spacer width="3px"/></td>
                    <td>
                        <a4j:commandButton value="#{messages['fina2.cancel']}" style="width:100px" onclick="Richfaces.hideModalPanel('bank_add_panel')"/>
                    </td>
                </tr>
            </table>
           
      
                 
              
               
           </h:form>
           
       </rich:modalPanel>
       
      </body>
</html>